def singleton(cls):
    # TODO 实现一个单例装饰器
    _instance={}
    def __call__(*args, **kwargs):
        if cls not in _instance:
            _instance[cls]=cls(*args, **kwargs)
        return _instance[cls]
    return __call__

@singleton
class Test:
    pass


test1 = Test()
test2 = Test()

assert test1 is test2, "不是单例"